<%@ page isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Eventorama - your favorite event planning site!</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="/stylesheets/cloudywatersports_/styles.css" rel="stylesheet"
	type="text/css" />
</head>
<body>
<div id="header">
<h1><a href="/">Eventorama</a></h1>
<h2>Get a social life</h2>
</div>
<div id="menu"></div>
<div id="content">
<div id="left">

<h2>Events</h2>

<c:if test="${eventCount == '0'}">
	<p>No events to display. Please add an event.</p>
</c:if> <c:if test="${eventCount != '0'}">
	<p>No. of events: <c:out value="${eventCount}" /></p>
</c:if> <c:forEach var="event" items="${allEvents}">

	<hr />
	<h3><c:out value="${event.title}" /></h3>
	<hr />
	<c:out value="${event.comment}" />

	<c:if test="${event.anyoneAttending == false}">
		<p>There are no participants for this events</p>
	</c:if>

	<c:if test="${event.anyoneAttending}">
		<H4>Participants</H4>
		<ul>
			<c:forEach var="participant" items="${event.participants}">
				<li><c:out value="${participant.user.nickname}" /></li>
			</c:forEach>
		</ul>
	</c:if>

	<c:if test="${loggedin}">
		<c:if test="${event.currentUserParticipant}">
			<form action="/decline.do" method="post">
			<input type="hidden" name="eventId" value="${event.key.id}" />
			<input type="submit" value="Decline" />
			</form>
		</c:if>

		<c:if test="${event.currentUserParticipant == false}">
			<form action="/accept.do" method="post">
			<input type="hidden" name="eventId" value="${event.key.id}" />
			<input type="submit" value="Accept" />
			</form>
		</c:if>

		<c:if test="${event.canBeDeletedByCurrentUser}">
			<form action="/deleteevent.do" method="post">
			<input type="hidden" name="eventId" value="${event.key.id}" />
			<input type="submit" value="Delete event" />
			</form>

		</c:if>
	</c:if>

	<br />
	<br />
	<br />

</c:forEach></div>


<c:if test="${loggedin}">
	<div id="right">Logged in as ${currentUser.nickname}.
	<ul>
		<li><a href="${logouturl}">Log out</a></li>
	</ul>
</c:if> <c:if test="${loggedin == false}">
	<div id="right">You are not logged in.
	<ul>
		<li><a href="${loginurl}">Log in</a></li>
	</ul>
</c:if>

<hr />

<c:if test="${loggedin}">
	<h2>New event</h2>
	<form action="/newevent.do" method="post">
	Title
	<br />
	<input type="text" name="title" />
	<br />
	<br />
	Comment
	<br />
	<textarea name="comment" COLS=23 ROWS=6></textarea>
	<br />
	<br />

	<input type="submit" value="Create event" />
	</form>
</c:if></div>
</div>

</body>
</html>



